home *** CD-ROM | disk | FTP | other *** search
/ PC Advisor 2011 May / PC Advisor 190 E.iso / pc / ESSENTIALS / VLC Media Player 1.1 / vlc-1.1.5-win32.exe / lua / playlist / katsomo.lua < prev    next >
Encoding:
Text File  |  2010-11-13  |  2.0 KB  |  61 lines

  1. --[[
  2.    Translate www.katsomo.fi video webpages URLs to the corresponding
  3.    movie URL
  4.  
  5.  $Id$
  6.  Copyright ┬⌐ 2009 the VideoLAN team
  7.  
  8.  This program is free software; you can redistribute it and/or modify
  9.  it under the terms of the GNU General Public License as published by
  10.  the Free Software Foundation; either version 2 of the License, or
  11.  (at your option) any later version.
  12.  
  13.  This program is distributed in the hope that it will be useful,
  14.  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  GNU General Public License for more details.
  17.  
  18.  You should have received a copy of the GNU General Public License
  19.  along with this program; if not, write to the Free Software
  20.  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  21. --]]
  22.  
  23. -- Probe function.
  24. function probe()
  25.     return vlc.access == "http"
  26.         and string.match( vlc.path, "www.katsomo.fi" )
  27.         and ( string.match( vlc.path, "treeId" ) or string.match( vlc.path, "progId" ) )
  28. end
  29.  
  30. function find( haystack, needle )
  31.     local _,_,r = string.find( haystack, needle )
  32.     return r
  33. end
  34.  
  35. -- Parse function.
  36. function parse()
  37.     p = {}
  38.     if string.match( vlc.path, "progId" )
  39.     then
  40.        programid = string.match( vlc.path, "progId=(%d+)")
  41.        path = "http://www.katsomo.fi/metafile.asx?p="..programid.."&bw=800"
  42.        table.insert(p, { path = path; } )
  43.        return p
  44.     end
  45.     while true
  46.     do
  47.         line = vlc.readline()
  48.         if not line then break end
  49.         if string.match( line, "<title>" )
  50.         then
  51.             title = vlc.strings.decode_uri( find( line, "<title>(.-)<" ) )
  52.         end
  53.         for programid in string.gmatch( line, "<li class=\"program\" id=\"program(%d+)\"" ) do
  54.             description = vlc.strings.resolve_xml_special_chars( find( line, "title=\"(.+)\"" ) )
  55.             path = "http://www.katsomo.fi/metafile.asx?p="..programid.."&bw=800"
  56.             table.insert( p, { path = path; name = title; description = description; url = vlc.path;} )
  57.         end
  58.     end
  59.     return p
  60. end
  61.